package lanou.giftsay_01.adapter;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import java.util.ArrayList;

import lanou.giftsay_01.fragment.body.BoyfriendFragment;
import lanou.giftsay_01.fragment.body.SelectFragment;
import lanou.giftsay_01.tools.URLValues;

/**
 * Created by dllo on 16/8/15.
 *
 */
public class Myadapter extends FragmentPagerAdapter {
    private Fragment[] fragments ;
    private String[] strings = {"精选", "送男票", "海淘", "创意生活", "科技苑", "送爸妈",
            "送基友", "送闺蜜", "送同事", "送宝贝", "设计感", "文艺风", "奇葩搞怪", "萌萌哒"};
    private final  String [] url = {URLValues.SONG_GIRLFRIEND, URLValues.HAITAO
            , URLValues.ORIGINALITY, URLValues.KEJI, URLValues.SONG_FSM
            , URLValues.SONG_FRIEND, URLValues.GIRL_FRIEND, URLValues.SONG_COLLEAGUE
            , URLValues.SONG_BABY, URLValues.DESIGN, URLValues.LITERATURE
            , URLValues.EXOTIC, URLValues.CUTE};

    public Myadapter(FragmentManager fm) {
        super(fm);
    }

    @Override
    public Fragment getItem(int position) {
        fragments  = new Fragment[strings.length];
        if (position == 0){
            fragments[0] = new SelectFragment();
        }else{
            fragments[position] = BoyfriendFragment.getInstance(url[position-1]);
        }

        return fragments[position] ;
    }

    @Override
    public int getCount() {
        return strings.length;
    }


    @Override
    public CharSequence getPageTitle(int position) {
        return strings[position];
    }
}
